package com.chinacache.maint.workorder.service;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;

import com.chinacache.maint.commons.orm.hibernate.Page;
import com.chinacache.maint.commons.orm.hibernate.SimpleHibernateDao;
import com.chinacache.maint.workorder.entity.FlowClass;

@Transactional
public class FlowClassManager {
	private SimpleHibernateDao<FlowClass, Integer> flowClassDao;

	@Required
	public void setSessionFactory(SessionFactory sessionFactory) {
		flowClassDao = new SimpleHibernateDao<FlowClass, Integer>(
				sessionFactory, FlowClass.class);
	}

	@Transactional(readOnly = true)
	public FlowClass getFlowClass(Integer id) {
		return flowClassDao.findById(id);
	}

	@Transactional(readOnly = true)
	public Page<FlowClass> getAllFlowClass(Page<FlowClass> page) {
		return flowClassDao.findAll(page);
	}

	public void saveFlowClass(FlowClass flowClass) {
		flowClassDao.save(flowClass);
	}

	public void deleteFlowClass(Integer id) {
		FlowClass flowClass = flowClassDao.findById(id);
		flowClassDao.delete(flowClass);
	}

	public void updateFlowClass(FlowClass flowClass) {
		flowClassDao.update(flowClass);
	}

	@Transactional(readOnly = true)
	public List<FlowClass> getAllFlowClass() {
		return flowClassDao.findAll();
	}
}
